package com.woniuxy.third.controller;

import com.woniuxy.third.annotation.RequirePermission;
import com.woniuxy.third.entity.Goods;
import com.woniuxy.third.result.ResponseResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RequestMapping("/goods")
@RestController
public class GoodsController {
     //
    @RequestMapping("/all")
    //指定访问该方法时的权限
    @RequirePermission("goods:all")
    public ResponseResult<List<Goods>> all(){
        //模拟从数据库中查到数据
        List<Goods> goods = Arrays.asList(
          new Goods(1001,"手机"),
          new Goods(1002,"电脑"),
          new Goods(1003,"笔记本"),
          new Goods(1004,"汽车")
        );
        //将数据进行封装
        ResponseResult<List<Goods>> responseResult = new ResponseResult<>();
        responseResult.setCode(200);
        responseResult.setMessage("success");
        responseResult.setData(goods);
        //
        return responseResult;
    }

}
